package com.bobo.medicinechest.adapter;

import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.bobo.medicinechest.R;
import com.bobo.medicinechest.bean.GoodsTypeBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;


public class GoodsTypeAdapter extends BaseQuickAdapter<GoodsTypeBean, BaseViewHolder> {

    public GoodsTypeAdapter(@Nullable List<GoodsTypeBean> data) {
        super(R.layout.item_goods_list_type, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsTypeBean item) {
        TextView tvType = helper.getView(R.id.tvType);
//        if (helper.getLayoutPosition() == 0) {
//            helper.setText(R.id.tvType, "全部");
//            tvType.setBackgroundColor(ContextCompat.getColor(mContext, R.color.purple_200));
//        } else {
//            helper.setText(R.id.tvType, item.getName());
////            tvType.setBackgroundColor(ContextCompat.getColor(mContext, com.bobo.base.R.color.app_blue));
//            if (item.isSelect()) {
//                helper.setBackgroundColor(R.id.tvType, ContextCompat.getColor(mContext, R.color.purple_200));
//            } else {
//                helper.setBackgroundColor(R.id.tvType, ContextCompat.getColor(mContext, com.bobo.base.R.color.app_blue));
//            }
//        }

        helper.setText(R.id.tvType, item.getName());
        if (item.isSelect()) {
            helper.setBackgroundRes(R.id.tvType, R.mipmap.ic_type_select);
            helper.setTextColor(R.id.tvType, ContextCompat.getColor(mContext, com.bobo.base.R.color.color_6874FE));
        } else {
            helper.setBackgroundColor(R.id.tvType, ContextCompat.getColor(mContext, com.bobo.base.R.color.app_color_transparent));
            helper.setTextColor(R.id.tvType, ContextCompat.getColor(mContext, com.bobo.base.R.color.app_color_white));
        }

    }

}